From 57379adb3c07f5794f90a2a8bba80347af43ac30 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Thu, 29 Dec 2011 16:18:12 +0100 Subject: [PATCH] css: Add generic support for 'inherit' and 'initial' CSS3 says they work for every property, so here we go. --- gtk/gtkcssprovider.c | 4 ++++ gtk/gtkcsstypesprivate.h | 2 +- gtk/gtkstyleproperty.c | 29 +++++++++++++++++++++++++++-- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 4aa4429665..e3fc75ac89 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -1533,6 +1533,10 @@ gtk_css_style_provider_lookup (GtkStyleProviderPrivate *provider, if (ruleset->style == NULL) continue; + if (!_gtk_bitmask_intersects (_gtk_css_lookup_get_missing (lookup), + ruleset->set_styles)) + continue; + if (!gtk_css_ruleset_matches (ruleset, path, state)) continue; diff --git a/gtk/gtkcsstypesprivate.h b/gtk/gtkcsstypesprivate.h index c0c884861a..ff1a844f2d 100644 --- a/gtk/gtkcsstypesprivate.h +++ b/gtk/gtkcsstypesprivate.h @@ -27,7 +27,7 @@ G_BEGIN_DECLS typedef enum { GTK_CSS_INHERIT, GTK_CSS_INITIAL, - GTK_CSS_CURRENT_COLOR + GTK_CSS_CURRENT_COLOR /*< nick=currentColor >*/ } GtkCssSpecialValue; typedef enum { diff --git a/gtk/gtkstyleproperty.c b/gtk/gtkstyleproperty.c index 5eade848a0..81f1cfda02 100644 --- a/gtk/gtkstyleproperty.c +++ b/gtk/gtkstyleproperty.c @@ -2326,7 +2326,30 @@ _gtk_style_property_parse_value (const GtkStyleProperty *property, if (property) { - if (_gtk_css_parser_try (parser, "none", TRUE)) + if (_gtk_css_parser_try (parser, "initial", TRUE)) + { + /* the initial value can be explicitly specified with the + * ‘initial’ keyword which all properties accept. + */ + g_value_unset (value); + g_value_init (value, GTK_TYPE_CSS_SPECIAL_VALUE); + g_value_set_enum (value, GTK_CSS_INITIAL); + return TRUE; + } + else if (_gtk_css_parser_try (parser, "inherit", TRUE)) + { + /* All properties accept the ‘inherit’ value which + * explicitly specifies that the value will be determined + * by inheritance. The ‘inherit’ value can be used to + * strengthen inherited values in the cascade, and it can + * also be used on properties that are not normally inherited. + */ + g_value_unset (value); + g_value_init (value, GTK_TYPE_CSS_SPECIAL_VALUE); + g_value_set_enum (value, GTK_CSS_INHERIT); + return TRUE; + } + else if (_gtk_css_parser_try (parser, "none", TRUE)) { /* Insert the default value, so it has an opportunity * to override other style providers when merged @@ -2383,7 +2406,9 @@ _gtk_style_property_print_value (const GtkStyleProperty *property, css_string_funcs_init (); - if (property) + if (G_VALUE_HOLDS (value, GTK_TYPE_CSS_SPECIAL_VALUE)) + func = enum_value_print; + else if (property) func = property->print_func; else func = NULL; -- 2.30.2